package com.huika.renrench.control.project.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.huika.renrench.GlobalApp;
import com.huika.renrench.R;
import com.huika.renrench.control.common.base.BaseAda;
import com.huika.renrench.model.ProjectCaseBean;

public class CaseListAdapter extends BaseAda<ProjectCaseBean> {

	public CaseListAdapter(Context context) {
		super(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView==null){
			convertView=View.inflate(mContext, R.layout.case_list_item, null);
			holder=new ViewHolder();
			holder.iv_big_item=(ImageView) convertView.findViewById(R.id.iv_big_item);
			holder.iv_case=(ImageView) convertView.findViewById(R.id.iv_case);
			holder.tv_case_name=(TextView) convertView.findViewById(R.id.tv_case_name);
			holder.tv_case_describe=(TextView) convertView.findViewById(R.id.tv_case_describe);
			holder.tv_category=(TextView) convertView.findViewById(R.id.tv_category);
			holder.tv_location=(TextView) convertView.findViewById(R.id.tv_location);
			holder.tv_key_word=(TextView) convertView.findViewById(R.id.tv_key_word);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		setDataFromNet(holder,position);
		return convertView;
	}
	

	private void setDataFromNet(ViewHolder holder, int position) {
		ProjectCaseBean projectCaseBean = getItem(position);
		holder.tv_case_describe.setText(projectCaseBean.description);
		holder.tv_case_name.setText(projectCaseBean.name);
		holder.tv_category.setText(projectCaseBean.category);
		holder.tv_location.setText(projectCaseBean.location);
		holder.tv_key_word.setText(projectCaseBean.keywords);
		GlobalApp.loadImgLoader(holder.iv_big_item, projectCaseBean.investImg);
		GlobalApp.loadImgLoader(holder.iv_case, projectCaseBean.logoPath);
	}


	class ViewHolder{
		public ImageView iv_big_item;
		public ImageView iv_case;
		public TextView tv_case_name;
		public TextView tv_case_describe;
		public TextView tv_category;
		public TextView tv_location;
		public TextView tv_key_word;
	}
	

}
